/**
 * 
 */
package com.beta.restapi.internal.annotation;

/**
 * @author vector
 * 权限策略
 */
public enum AuthStrategy {
	ANONYMOUS(0, "游客级别"), NEED_LOGIN(1, "需要登录"), NEED_AUTH(2, "需要授权");

	/** 主键 */
	private final int key;

	/** 描述 */
	private final String desc;

	private AuthStrategy(final int key, final String desc) {
		this.key = key;
		this.desc = desc;
	}

	public int getKey() {
		return this.key;
	}

	public String getDesc() {
		return this.desc;
	}

	public static AuthStrategy getAuthStrategy(int key) {
		AuthStrategy[] authStrategies = AuthStrategy.values();
		for (AuthStrategy authStrategy : authStrategies) {
			if (authStrategy.getKey() == key) {
				return authStrategy;
			}
		}
		return AuthStrategy.NEED_LOGIN;
	}
}
